/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tools;

import graphics.Credits;
import java.awt.Component;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import user.Statistic;

/**
 *
 * @author Mattia
 */
public class MessageManager {
    public static void generic(Component parent,String message, String title, int messageType) {
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" show message - Title: \""+title+"\" Message: \""+message+"\"");
        JOptionPane.showMessageDialog(parent, message, title, messageType);
    }
    public static void error(Component parent, String message, String title) {
        System.err.println("==================================\nERROR\nTitle:\t"+title+"\nMessage:\t"+message+"\n==================================");
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" has error    - Title: \""+title+"\" Message: \""+message+"\"");
        JOptionPane.showMessageDialog(parent, message, title, JOptionPane.ERROR_MESSAGE);
    }
    public static void warning(Component parent, String message, String title) {
        System.err.println("==================================\nWARNING\nTitle:\t"+title+"\nMessage:\t"+message+"\n==================================");
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" has warning  - Title: \""+title+"\" Message: \""+message+"\"");
        JOptionPane.showMessageDialog(parent, message, title, JOptionPane.WARNING_MESSAGE);
    }
    public static void downloadError(Component parent,String message) {
        System.err.println("==================================\nDOWNLOAD ERROR\n"+message+"\n==================================");
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" has error    - Title: \"Errore di Download\" Message: \""+message+"\"");
        JOptionPane.showMessageDialog(parent, message, "Errore di Download", JOptionPane.ERROR_MESSAGE);
    }
    public static void info(Component parent,String message, String title) {
        System.err.println("==================================\nINFO\nTitle:\t"+title+"\nMessage:\t"+message+"\n==================================");
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" has info     - Title: \""+title+"\" Message: \""+message+"\"");
        JOptionPane.showMessageDialog(parent, message, title, JOptionPane.INFORMATION_MESSAGE);
    }
    public static void logger(String message) {
        Statistic.updateStatFile(TimeManager.getTimeToString()+" - "+System.getProperty("user.name")+" log: \""+message+"\"");
    }
    public static void browserNavigateTo(String url) {
        try {
            Desktop.getDesktop().browse(new URI(url));
        } catch (URISyntaxException ex) {
            Logger.getLogger(Credits.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Credits.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    static String httpResponseCodeToString(String responseMessage) {
        return responseMessage;
    }
}
